﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._23_访问者模式
{
    /// <summary>
    /// 购物车类
    /// </summary>
    public class ShopCart
    {
        private readonly List<MyProduct> _products = new List<MyProduct>();

        public void AddProduct(MyProduct product)
        {
            _products.Add(product);
        }

        public void Process(IVisitor visitor)
        {
            foreach (var product in _products)
            {
                product.Accept(visitor);
            }
        }

    }
}
